import gdata from 'gdata';
import  {getucDomain} from  '../../pages/membership2/member/script/dynamicData';
import request from 'request';
import {message} from 'antd';
let util = { };
/**
 * @func 去用户中心登录
 */
util.toLogin = function(){
    if(gdata('ucDomain')){
        window.location.href = gdata('ucDomain')+'/Contents/usercenter/allow/login/login.jsp?redirecturl=jss&jumpurl='+ encodeURIComponent(location.href);
    }
    else {
        getucDomain(()=>{
            window.location.href = gdata('ucDomain')+'/Contents/usercenter/allow/login/login.jsp?redirecturl=jss&jumpurl='+ encodeURIComponent(location.href);
        })
    }
}
util.loginout = function(){
    request.get('login/loginout.action')
    .then((res)=>{
        if(res.result == 'true'){    
            window.location.href = res.param+'&jumpurl='+ encodeURIComponent(location.href);
        }
        else{
            message.error(res.message);
        }
    })
}

export default util;